//
// Created by Vincent-Vic on 2020/3/11.
//

#ifndef DATAORGANIZATION_CMAP_H
#define DATAORGANIZATION_CMAP_H

#include <iostream>
#include <vector>
#include <memory.h>

#include "Node.h"
using namespace std;

class CMap {
public:
    CMap(int capacity);
    virtual ~CMap();
    bool addNode(Node* pNode);      //图添加节点
    void resetNode();               //重置节点
    bool setValueToMatrixForDirectedGraph(int row,int col,int val = 1);     //为有向图设置邻接矩阵
    bool setValueToMatrixForUndirectedGraph(int row,int col,int val = 1);   //为无向图设置邻接矩阵
    void depthFirstTraverse(int nodeIndex);     //深度优先遍历
    void breadthFirstTraverse(int nodeIndex);   //广度优先遍历
    void printMatrix();     //打印邻接矩阵
    bool isEmpty();         //判断图是否为空
private:
    bool getValueFromMatrix(int row,int col,int &val);      //从矩阵中获取权值
    void breadthFirstTraverseImpl(vector<int> preVec);      //广度优先遍历实现函数

private:
    int m_iCapacity;    //图中最多可以容纳的顶点数
    int m_iNodeCount;   //已经添加的顶点（结点）个数
    Node* m_pNodeArray; //用来存放的顶点数组
    int *m_pMatrix;     //用来存放邻接矩阵




};


#endif //DATAORGANIZATION_CMAP_H
